package StudyCode.summary.mycollection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class ConjunctCollections {
	public static void main(String[] argv) {
		Collection list1 = java.util.Arrays.asList("科技与人文", "www.tah1986.com", "1", "2");
		Collection list2 = java.util.Arrays.asList("科技与人文", "www.tah1986.com", "1");
		System.out.println(conjunctCollections(list1, list2));
	}

	private static <T> List<T> conjunctCollections(final Collection<T> list1, final Collection<T> list2) {
		final HashSet<T> s1 = new HashSet<T>(list1);
		s1.retainAll(list2);
		return new ArrayList<T>(s1);
	}

}
